library(dplyr)
library(purrr)
library(here)
library(fs)
library(glue)
library(sf)
library(mapview)
dir_img <- "/Users/bbest/Gdrive Ecoquants/projects/nms-web/cinms/Images"
# functions ----
convert_fig <- function(fig_beg, fig_end, redo=F){
stopifnot(file.exists(fig_beg), dir.exists(dirname(fig_end)))
#browser()
if (!file.exists(fig_end) | redo){
cmd <- glue("magick convert '{fig_beg}' -resize 800 -alpha on '{fig_end}'")
system(cmd)
paths_01 <- glue("{path_ext_remove(fig_end)}-{c(0,1)}.png")
if (all(file.exists(paths_01))){
file_copy(paths_01[2], fig_end, overwrite = T)
file_delete(paths_01)
}
}
}
get_nms_ply <- function(nms){
# eg get_nms_ply("cinms")
# get polygon for National Marine Sanctuary
nms_shp <- here(glue("data/shp/{nms}_py.shp"))
if (!file.exists(nms_shp)){
# download if needed
# https://sanctuaries.noaa.gov/library/imast_gis.html
nms_url <- glue("https://sanctuaries.noaa.gov/library/imast/{nms}_py2.zip")
nms_zip <- here(glue("data/{nms}.zip"))
shp_dir <- here("data/shp")
download.file(nms_url, nms_zip)
unzip(nms_zip, exdir = shp_dir)
file_delete(nms_zip)
}
# read and convert to standard geographic projection
read_sf(nms_shp) %>%
st_transform(4326)
}
figs <- list(
folder = "State - Living Resources (S.LR.Q#.#)",
figure = c(
"S.LR.12.5a_Anchovy_CalCOFI.tif",
"S.LR.12.5b_Sardine_CalCOFI.tif",
"S.LR.12.5c_Squid_CalCOFI.tif"))
figs_beg <- path(dir_img, figs$folder, figs$figure)
figs_end <- here(glue("docs/figures/{path_ext_remove(basename(figs_beg))}.png"))
walk2(figs_beg, figs_end, convert_fig)
knitr::include_graphics(figs_end)
Figure S.LR.12.5. Relative abundance of Northern anchovy Engraulis mordax (top), Pacific sardine Sardinops sagax (middle), and market squid Doryteuthis opalescens (bottom) in bongo nets deployed during spring California Cooperative Oceanic Fisheries Investigations (CalCOFI) cruises at sites in the Channel Islands National Marine Sanctuary (CINMS) region from 1978–2015 (except squid collected since 1997). Horizontal lines show the mean (dashed line) ± 1.0 standard deviation (solid lines) over the full time series. Symbol at upper right indicates whether data over the last five years (green shaded areas) had a positive trend (⬈), a negative trend (⬊), or no trend (↔). Symbol at lower right indicates whether the mean over the past five years was greater than (+), less than (–), or within 1 standard deviation (●) of the mean of the full time series. It is important to note that a mean abundance of zero does not mean that the species is completely absent from the waters off of southern California, but that it was not collected at any sites around CINMS during the spring survey that year (sampling locations shown in Appendix F: Figure App.F.12.17). Data source: CalCOFI; Figure: A. Thompson/NMFS SWFSC
Larval fish in nets
figs <- list(
folder = "State - Living Resources (S.LR.Q#.#)",
figure = c(
"S.LR.15.3a_Cool-water.tif",
"S.LR.15.3b_warm-water.tif",
"S.LR.15.3c_species_richness.tif",
"S.LR.15.3d_Simpson_diversity.tif"))
figs_beg <- path(dir_img, figs$folder, figs$figure)
figs_end <- here(glue("docs/figures/{path_ext_remove(basename(figs_beg))}.png"))
walk2(figs_beg, figs_end, convert_fig)
knitr::include_graphics(figs_end)
Figure S.LR.15.3. (Top) Mean abundance of (left) cool-water associated and (right) warm-water associated ichthyoplankton (larval fishes) collected in net samples during CalCOFI cruises in spring and summer at sites in the Channel Islands National Marine Sanctuary region from 1978 to 2015. (Bottom) The average species richness (left) and species diversity (right) in each net sample is shown for the entire time series. Gini-Simpson diversity (1-λ form) is a measure of the equitability of species in a sample. When individuals are well-distributed among species, Gini-Simpson diversity is high. Graph format is explained in Figure S.LR.12.4. The warm water event also influenced the relative abundance of warm-water species at higher trophic levels including predatory fish, seabirds, and marine mammals. For example, there were increased sightings of species not usually observe
figs <- list(
folder = "App F: LR (AppF.Q#.#)/AppendixF_Q12",
figure = c(
"App.F.12.17.Map_CalCOFI.tiff"))
figs_beg <- path(dir_img, figs$folder, figs$figure)
figs_end <- here(glue("docs/figures/{path_ext_remove(basename(figs_beg))}.png"))
walk2(figs_beg, figs_end, convert_fig)
knitr::include_graphics(figs_end)
Figure App.F.12.17. Location of spring season net samples by the California Cooperative Oceanic Fisheries Investigations (CalCOFI) used in analyses of abundance and trends in pelagic resources in two regions: Channel Islands National Marine Sanctuary region (red) includes CalCOFI stations inside and adjacent to CINMS; and Southern California Shelf (yellow) includes all CalCOFI stations over the shelf. Figure: A. Thompson/NOAA
figs <- list(
folder = "App F: LR (AppF.Q#.#)/AppendixF_Q12",
figure = c(
"App.F.12.18_CalCOFI_SPV.tiff"))
figs_beg <- path(dir_img, figs$folder, figs$figure)
figs_end <- here(glue("docs/figures/{path_ext_remove(basename(figs_beg))}.png"))
walk2(figs_beg, figs_end, convert_fig)
knitr::include_graphics(figs_end)
Figure App.F.12.18. Mean volume of small plankton collected in net samples during CalCOFI cruises at only sites in the Channel Islands National Marine Sanctuary region (top) and all sites over the Southern California Shelf (bottom) from 1978 to 2015 (sampling locations shown in Figure App.F.12.17). Horizontal lines show the mean (dashed line) ± 1.0 standard deviation (solid lines) over the full time series. Symbol at upper right indicates whether data over the last five years (green shaded areas) had a positive trend (), a negative trend (), or no trend (↔). Symbol at lower right indicates whether the mean over the past five years was greater than (+), less than (–), or within 1 standard deviation (●) of the mean of the full time series.. Figure App.C.4.15. Variation over time in percentage of stations from winter CalCOFI cruises with plastic micro-debris. Micro-debris was present in more than 50 percent of samples at each time period. Figure: Gilfillan et al. 2009
figs <- list(
folder = "App F: LR (AppF.Q#.#)/AppendixF_Q12",
figure = c(
"App.F.12.19b.CalCOFI_Med_ichthy.tiff",
"App.F.12.19a.CalCOFI_High_ichthy.tiff"))
figs_beg <- path(dir_img, figs$folder, figs$figure)
figs_end <- here(glue("docs/figures/{path_ext_remove(basename(figs_beg))}.png"))
walk2(figs_beg, figs_end, convert_fig)
knitr::include_graphics(figs_end)
Figure App.F.12.19. Relative abundance of key forage groups collected in net samples during spring CalCOFI cruises at sites in the Channel Islands National Marine Sanctuary (CINMS) region from 1978 to 2015. Forage is grouped by high (left panel) and medium (right panel) energy density. High energy taxa are Pacific sardines, northern anchovies, and and Myctophids. Medium- energy taxa are Pacific hake, shortbelly rockfish, and sanddabs. Although sardine were completely absent in net samples from 2011 to 2014 in the CINMS region, comparison with samples collected in the larger Southern California Shelf region reveal that sardine were at very low abundance but not completely absent from the region (sampling locations shown in Figure App.F12.17). Symbols on graph explained in the caption of Figure App.F12.18. Data source: CalCOFI; Figure: A. Thompson/NOAA
figs <- list(
folder = "App F: LR (AppF.Q#.#)/AppendixF_Q12",
figure = c(
"App.F.12.20.CalCOFI_squid.tiff"))
figs_beg <- path(dir_img, figs$folder, figs$figure)
figs_end <- here(glue("docs/figures/{path_ext_remove(basename(figs_beg))}.png"))
walk2(figs_beg, figs_end, convert_fig)
knitr::include_graphics(figs_end)
Figure App.F.12.20. Mean abundance of market squid (Doryteuthis opalescens) collected in net samples during CalCOFI cruises at only sites in the Channel Islands National Marine Sanctuary region (top) and all sites over the Southern California Shelf (bottom) from 1997 to 2015 (sampling locations shown in Figure App.F12.17). Symbols on graph explained in the caption of Figure App.F12.18. Data source: CalCOFI; Figure: A. Thompson/NOAA
library(rerddap)
stns <- tabledap('erdCalCOFIstns')
View(stns)
## pull in data taken from erddap
## this file came from the link: CalCOFI Larvae Counts, Scientific Names SB to SC
# see: https://coastwatch.pfeg.noaa.gov/erddap/search/index.html?page=1&itemsPerPage=1000&searchFor=CalCOFI+Larvae+Counts
raw1 <- read.csv("erdCalCOFIlrvcntSBtoSC_5e28_d9ef_0ecc.csv")
info("erdCalCOFIlrvcntSBtoSC")
#flds <- c("calcofi_species_code", "station", "line", "longitude", "latitude", "net_location")
#d_lrvcntSBtoSC <- tabledap("erdCalCOFIlrvcntSBtoSC", fields=flds) #%>%
d_lrvcntSBtoSC <- tabledap("erdCalCOFIlrvcntSBtoSC") #%>%
d_lrvcntSBtoSC <- d_lrvcntSBtoSC %>%
mutate(
lon = as.numeric(longitude),
lat = as.numeric(latitude)) %>%
select(-longitude, -latitude)
summary(d_lrvcntSBtoSC)
stns <- d_lrvcntSBtoSC %>%
group_by(station, line) %>%
summarize(
lon_mean = mean(lon),
lon_min = min(lon),
lon_max = max(lon),
lon_dif = lon_max - lon_min,
lat_mean = mean(lat),
lat_min = min(lat),
lat_max = max(lat),
lat_dif = lat_max - lat_min)
View(stns)
View(d_lrvcntSBtoSC)
datasets <- ed_search(query = "CalCOFI", which = "tabledap")
datasets
info()
p_cinms <- get_nms_ply("cinms")
#mapview::mapview(p_cinms)
st_join(pts, poly, join = st_intersects)
summary(d_lrvcntSBtoSC)
p_lrvcntSBtoSC <- st_as_sf(d_lrvcntSBtoSC, coords = c("lon", "lat"), crs = 4326)
p_stns <- st_as_sf(stns, coords = c("lon_mean", "lat_mean"), crs = 4326)
p_lrvcntSBtoSC <- st_join(p_lrvcntSBtoSC, select(p_cinms, SANCTUARY))
table(p_lrvcntSBtoSC$SANCTUARY, useNA="always")
plot(p_cinms["SANCTUARY"])
plot(p_cinms[1])
plot(p_lrvcntSBtoSC[1], add=T)
mapview(p_cinms) + mapview(p_lrvcntSBtoSC)
mapview(p_cinms) + mapview(p_lrvcntSBtoSC %>% filter(SANCTUARY=="CINMS")
sf::st_covered_by()